/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.tms.module.demandorder.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.tms.global.config.LocalDateTimeConverter;
import org.springblade.tms.global.exception.CommonException;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 需求单实体类
 *
 * @author Blade
 * @since 2022-03-03
 */
@Data
@TableName("tm_demand_order")
@EqualsAndHashCode(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "DemandOrder对象", description = "需求单")
public class TMDemandOrder extends TenantEntity {

	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	@ApiModelProperty(value = "主键")
	private Long id;
	/**
	 * 需求单号
	 */
	@ApiModelProperty(value = "需求单号")
	@ExcelProperty(value = "需求单号")
	private String demandOrderNumber;
	/**
	 * 货运订单号
	 */
	@ApiModelProperty(value = "货运订单号")
	@ExcelProperty(value = "货运订单号")
	private String orderNo;
	/**
	 * 货运订单类型
	 */
	@ApiModelProperty(value = "货运订单类型")
	@ExcelProperty(value = "货运订单类型")
	private String orderType;
	/**
	 * 交货单号
	 */
	@ApiModelProperty(value = "交货单号")
	@ExcelProperty(value = "交货单号")
	private String deliverNo;
	/**
	 * 源位置
	 */
	@ApiModelProperty(value = "源位置")
	@ExcelProperty(value = "源位置")
	private String startLocationNo;
	/**
	 * 源位置名称
	 */
	@ApiModelProperty(value = "源位置名称")
	@ExcelProperty(value = "源位置名称")
	private String startLocationName;
	/**
	 * 原位置区域（省份）
	 */
	@ApiModelProperty(value = "原位置区域（省份）")
	@ExcelProperty(value = "原位置区域")
	private String startLocationArea;
	/**
	 * 源位置城市
	 */
	@ApiModelProperty(value = "源位置城市")
	@ExcelProperty(value = "源位置城市")
	private String startLocationCity;
	/**
	 * 源位置街道
	 */
	@ApiModelProperty(value = "源位置街道")
	@ExcelProperty(value = "源位置街道")
	private String startLocationStreet;
	/**
	 * 承运商编码
	 */
	@ApiModelProperty(value = "承运商编码")
	private String carrierNo;
	/**
	 * 承运商名称
	 */
	@ApiModelProperty(value = "承运商名称")
	@ExcelProperty(value = "承运商名称")
	private String carrierName;
	/**
	 * 计划提货日期
	 */
	@ApiModelProperty(value = "计划提货日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelProperty(value = "计划提货日期", converter = LocalDateTimeConverter.class)
	private LocalDateTime planGetGoodsDateStart;
	/**
	 * 计划收货日期
	 */
	@ApiModelProperty(value = "计划收货日期")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelProperty(value = "计划收货日期", converter = LocalDateTimeConverter.class)
	private LocalDateTime planGetGoodsDateEnd;
	/**
	 * 备注
	 */
	@ApiModelProperty(value = "备注")
	@ExcelProperty(value = "备注")
	private String remark;
	/**
	 * 目标位置
	 */
	@ApiModelProperty(value = "目标位置")
	@ExcelProperty(value = "目标位置")
	private String targetLocationNo;
	/**
	 * 目标位置名称
	 */
	@ApiModelProperty(value = "目标位置名称")
	@ExcelProperty(value = "目标位置名称")
	private String targetLocationName;
	/**
	 * 承运商ID
	 */
	@ApiModelProperty(value = "承运商ID")
	private Long carrierId;
	/**
	 * 目标位置区域（省份）
	 */
	@ApiModelProperty(value = "目标位置区域（省份）")
	@ExcelProperty(value = "目标位置区域")
	private String targetLocationArea;
	/**
	 * 目标位置城市
	 */
	@ApiModelProperty(value = "目标位置城市")
	@ExcelProperty(value = "目标位置城市")
	private String targetLocationCity;
	/**
	 * 目标位置街道
	 */
	@ApiModelProperty(value = "目标位置街道")
	@ExcelProperty(value = "目标位置街道")
	private String targetLocationStreet;

	/**
	 * 需求单状态
	 */
	@ApiModelProperty(value = "需求单状态")
	@ExcelProperty(value = "需求单状态")
	private String demandStatus;
	/**
	 * 运输方式
	 */
	@ApiModelProperty(value = "运输方式")
	@ExcelProperty(value = "运输方式")
	private String ysfsDes;
	/**
	 * 联系人
	 */
	@ApiModelProperty(value = "联系人")
	@ExcelProperty(value = "联系人")
	private String khlxr;
	/**
	 * 联系方式
	 */
	@ApiModelProperty(value = "联系方式")
	@ExcelProperty(value = "联系方式")
	private String khlxfs;
	/**
	 * 提货地址
	 */
	@ApiModelProperty(value = "提货地址")
	@ExcelProperty(value = "提货地址")
	private String thdz;
	/**
	 * 包装方式
	 */
	@ApiModelProperty(value = "包装方式")
	@ExcelProperty(value = "包装方式")
	private String bzfs;
	/**
	 * 包装数量
	 */
	@ApiModelProperty(value = "包装数量")
	@ExcelProperty(value = "包装数量")
	private String bzsl;
	/**
	 * 收发工厂
	 */
	@ApiModelProperty(value = "收发工厂")
	@ExcelProperty(value = "收发工厂")
	private String werks;
	/**
	 * 收发工厂描述
	 */
	@ApiModelProperty(value = "收发工厂描述")
	@ExcelProperty(value = "收发工厂描述")
	private String werksName;
	/**
	 * 客户名称
	 */
	@ApiModelProperty(value = "客户名称")
	@ExcelProperty(value = "客户名称")
	private String customerName;
	/**
	 * 国际贸易条款
	 */
	@ApiModelProperty(value = "国际贸易条款")
	@ExcelProperty(value = "国际贸易条款")
	private String tradeTerms;
	/**
	 * 国际贸易条款附加信息
	 */
	@ApiModelProperty(value = "国际贸易条款附加信息")
	@ExcelProperty(value = "国际贸易条款附加信息")
	private String tradeTermsItem;

	/**
	 * 提单号
	 */
	@ApiModelProperty(value = "提单号")
	@ExcelProperty(value = "提单号")
	private String billOfLadingNumber;

	@ApiModelProperty("订单号")
	@ExcelProperty(value = "订单号")
	private String orderNumber;

	@ApiModelProperty("作废原因")
	@ExcelProperty(value = "作废原因")
	private String reasonForVoiding;

	@ApiModelProperty("合同公司")
	@ExcelProperty(value = "合同公司")
	private String contractCompany;

	@ApiModelProperty("是否已删除")
	private Integer isDeleted;

	@ApiModelProperty("分包商id")
	private String fbsId;

	@ApiModelProperty("分包商名字")
	@ExcelProperty(value = "分包商名字")
	private String fbsName;

	/***
	 * 根据情况返回MP的wrapper
	 * @param type
	 * @param entity
	 * @return
	 */
	public static LambdaQueryWrapper<TMDemandOrder> buildWrapper(Integer type, TMDemandOrder entity) {
		LambdaQueryWrapper<TMDemandOrder> result = new LambdaQueryWrapper<>();
		switch (type) {
			case 1:
				//仅设置 eq 货运订单号
				result.eq(TMDemandOrder::getOrderNo, entity.getOrderNo());
				break;
			default:
				CommonException.throwCommonException("错误类型");
		}
		return result;
	}
}
